/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package cz.mzk.lidovky.articles.domain;

/**
 *
 * @author Martin Řehánek (rehan@mzk.cz)
 */
public enum DayTime {

    firstMorning, morning, afternoon, evening, small, unspecified;

    public static DayTime parseString(String string) {
        for (DayTime dt : DayTime.values()) {
            if (string.contains(dt.toString())) {
                return dt;
            }
        }
        return unspecified;
    }

    @Override
    public String toString() {
        switch (this) {
            //"1. ranní" value must be before "raní"
            //because values of this enum are being iterated until string.contains(DayTime.toString()) retuns true
            //so if ranni was before 1. ranni, ranni would incorrectly success first
            case firstMorning:
                return "1. ranní";
            case morning:
                return "ranní";
            case afternoon:
                return "odpolední";
            case evening:
                return "večerní";
            case small:
                return "malé";
            case unspecified:
                return "neurčené";
            default:
                return "neznámé";
        }
    }
}
